<%@page import="com.wed.db.ConnectDB"%>
<%@page import="com.wed.db.SanPham"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>THÔNG TIN SÁCH</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/dataTables.colReorder.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/dataTables.colVis.css">

<style type="text/css" class="init">
</style>
<script type="text/javascript" language="javascript"
	src="${pageContext.request.contextPath}/js/jquery.js"></script>
<script type="text/javascript" language="javascript"
	src="${pageContext.request.contextPath}/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript"
	src="${pageContext.request.contextPath}/js/dataTables.colReorder.js"></script>
<script type="text/javascript" language="javascript"
	src="${pageContext.request.contextPath}/js/dataTables.colVis.js"></script>


<script type="text/javascript" language="javascript" class="init">


$(document).ready(function() {
    var table = $('#example').DataTable( {
        dom: 'RC<"clear">lfrtip',
        columnDefs: [
            { visible: false, targets: 1 }
        ]
	} );
} );


	</script>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/Style.css" type="text/css"
	charset="utf-8" />

</head>



<body>
	<div id="background">
		<div id="page">
			<div id="header"></div>
			<!-- /#header -->
			<div id="contents">
				<ul id="navigation">
					<li><a href="TrangChu.jsp">Trang Chủ</a></li>
					<li><a href="#"> Giới Thiệu</a></li>
				<li><a href="#">Hoạt Động</a></li>
					<li class="selected"><a href="ThongTinSach.jsp">Quản Lí</a></li>
					<li><a href="login.jsp">Thoát</a></li>


				</ul>
				<%ArrayList<SanPham> lst = new ConnectDB().getAllProducts();%>
				<div id="main">
					<form id="form1" name="from1" method="post" action="">
						<table id="example" class="display" cellspacing="0" width="100%">

							<thead>
								<tr background="#800517">
									<td width="5%" height="26" bgcolor="#800517">Chọn</td>
									<td width="5%" height="26" bgcolor="#CC6600">Mã Sách</td>
									<td width="20%" bgcolor="#CC6600">Tên Sách</td>
									<td width="10%" bgcolor="#CC6600">Thể Loại</td>
									<td width="10%" bgcolor="#CC6600">Tác Giả</td>
									<td width="10%" bgcolor="#CC6600">NXB</td>
									<td width="10%" bgcolor="#CC6600">Giá Nhập</td>
									<td width="10%" bgcolor="#CC6600">Giá Bán</td>
									<td width="5%" bgcolor="#CC6600">Hình Ảnh</td>
									<td width="10%" bgcolor="#CC6600"><a href="QuanLiSach.jsp">Thêm
											Mới</a></td>
								</tr>
							</thead>
							<tbody>
								<%
				 for(SanPham sp : lst){
					 String viewImage = "XemHinhAnh.jsp?MaSach="+sp.getMaSach();;
					 String editURL = "CapNhatTT.jsp?MaSach="+sp.getMaSach();;
					 String deleteURL = "DeleteServlet?MaSach="+sp.getMaSach();
				 
				%>
								<tr>
									<td><input type="checkbox" name="checkbox"></input></td>
									<td><%=sp.getMaSach() %></td>
									<td><%=sp.getTenSach() %></td>
									<td><%=sp.getTheLoai() %></td>
									<td><%=sp.getTacGia() %></td>
									<td><%=sp.getNXB() %></td>
									<td><%=sp.getGiaNhap() %></td>
									<td><%=sp.getGiaXuat() %></td>
									<td><a href="<%=viewImage%>">Xem Ảnh </a></td>
									<td><a href="<%=deleteURL%>">Xóa</a>-<a
										href="<%=editURL%>">Sửa</a></td>
								</tr>
								<% 
					}
					 %>

							</tbody>
						</table>
					</form>
				</div>
</body>
</html>